package com.vic.kjlink.order.config;

import com.vic.kjlink.order.service.IndexService;
import com.vic.kjlink.order.web.AuthenticationIntercepter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import pers.vic.boot.base.web.intercept.SaveRequestInterceptor;

/**
 * @author Vic.xu
 * @description:
 * @date: 2021/8/20 0020 17:30
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private IndexService indexService;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration registration = registry.addInterceptor(new AuthenticationIntercepter(indexService));
        registration.addPathPatterns("/**").excludePathPatterns("/login").excludePathPatterns("/static/**", "/css/**",
                "/js/**", "/assets/**");
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(new SaveRequestInterceptor());
        interceptorRegistration.addPathPatterns("/**");

    }
}
